﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RubricaSentimentale.Model;
using System.Globalization;

namespace RubricaSentimentale
{
	public partial class DataDetails : UserControl
	{
        public string Intestazione { get; set; }
        public string tipo="film";
		public DataDetails()
		{
			// Required to initialize variables
			InitializeComponent();
			btnAdd.Click+=new System.Windows.RoutedEventHandler(btnAdd_Click);
		}

        private void btnAdd_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                DateTime dt = DateTime.ParseExact(tbxData.Text, "dd/MM/yyyy",CultureInfo.InvariantCulture );
                string t = tbxDesc.Text;
                (DataContext as FormattedList<ImportantDate>).Add(new ImportantDate(t,dt));
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Formato della data errato");
            }
            catch
            {
                MessageBox.Show("Errore");
            }

            
        }

        private void Image_Tap(object sender, GestureEventArgs e)
        {
            (DataContext as FormattedList<ImportantDate>).Remove((ImportantDate)(sender as Image).DataContext);
        }
		

	}
}